<< define "menu/create.html" >>
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>添加菜单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <link rel="stylesheet" href="/static/css/mbgadmin.css">
    <script src="/static/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <script type="text/javascript" src="/static/js/mbgadmin.js"></script>
</head>
<body>
<form class="layui-form" lay-filter="menus_add_form">
    <div class="layui-form-item">
        <label class="layui-form-label">父菜单ID<span class="x-red">*</span></label>
        <div class="layui-input-block">
            <input type="text" name="parent_id"  placeholder="" autocomplete="off"
                   class="layui-input layui-disabled">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">父菜单名称<span class="x-red">*</span></label>
        <div class="layui-input-block">
            <input type="text" name="parent_name"  placeholder="" autocomplete="off"
                   class="layui-input layui-disabled">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">新菜单名称<span class="x-red">*</span></label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" placeholder="请输入新菜单名称" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">类型<span class="x-red">*</span></label>
        <div class="layui-input-block">
            <input type="radio" name="type" value="0" title="菜单" checked>
            <input type="radio" name="type" value="1" title="按钮">
            <input type="radio" name="type" value="2" title="资源">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图标</label>
        <div class="layui-input-block">
            <input type="text" name="icon" placeholder="请输入图标" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">URL</label>
        <div class="layui-input-block">
            <input type="text" name="url" placeholder="请输入URL" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">请求类型</label>
        <div class="layui-input-block">
            <select name="request_type" lay-filter="request_type">
                <option value=""></option>
                <option value="GET" selected>GET</option>
                <option value="POST">POST</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">层级</label>
        <div class="layui-input-block">
            <input type="text" name="level" placeholder="" autocomplete="off" class="layui-input layui-disabled">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="addAdmin" id="submit">立即提交</button>
        </div>
    </div>
</form>

<script>
    function child(dataFromFather) {
    layui.use(['form','layer'], function () {
        var form = layui.form;
        let layer = layui.layer;

        form.val('menus_add_form', {
            "parent_id": dataFromFather.ID,
            "parent_name": dataFromFather.name,
            "level":dataFromFather.level+1,
        });
        form.on('submit(addAdmin)', function (data) {
            $("#submit").addClass("layui-btn-disabled") //防止连续点击添加键。
            let loadIndex = layer.load(2);
            $.post("/menus/createMenus", data.field, function (result) {
                if (result.code === 0) {
                    layer.close(loadIndex)
                    parent.layer.msg(result.msg);
                    ReloadLists()
                } else {
                    layer.close(loadIndex)
                    layer.msg(result.msg)
                    $("#submit").removeClass("layui-btn-disabled")
                }
            });
            return false;
        });
    });
    }
</script>

</body>
</html>
<< end >>